<?php

namespace app\common\service\order\order_status\items;

use app\model\CouponOrder;

/**
 * 已完成
 */
class OrderStatusFinish extends OrderStatusBase
{
    public static function handle(CouponOrder $couponOrder, $next)
    {

        //支付状态
        if (CouponOrder::C_PAY_STATUS_YES != $couponOrder->pay_status) {
            return $next($couponOrder);
        }

        //订单状态
        if (CouponOrder::C_STATUS_RECHARGE_SUCCESS != $couponOrder->status) {
            return $next($couponOrder);
        }

        //结算状态
        if (!in_array($couponOrder->agent_settle_status, [
            CouponOrder::C_AGENT_SETTLE_STATUS_WAIT,
        ])) {
            return $next($couponOrder);
        }

        $couponOrder->params['return_status'] =  self::getReturnStatus(self::FINISH);

        return $next($couponOrder);

    }
}